home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkTextIO.h.z / VkTextIO.h
C/C++ Source or Header  |  1996-09-20  |  4KB  |  108 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  3. //                                                                            //
  4. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  5. // the contents of this file may not be disclosed to third parties, copied    //
  6. // or duplicated in any form, in whole or in part, without the prior written  //
  7. // permission of Silicon Graphics, Inc.                                       //
  8. //                                                                            //
  9. // RESTRICTED RIGHTS LEGEND:                                                  //
  10. // Use,duplication or disclosure by the Government is subject to restrictions //
  11. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  12. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  13. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  14. // rights reserved under the Copyright Laws of the United States.             //
  15. //                                                                            //
  16. ////////////////////////////////////////////////////////////////////////////////
  17. #ifndef _VK_TEXT_IO_
  18. #define _VK_TEXT_IO_
  19.  
  20. #include <Vk/VkComponent.h>
  21.  
  22. #include <Xm/Xm.h>
  23.  
  24. enum VkTextIOReason { TIO_input, TIO_ctrlc };
  25.  
  26. typedef struct {
  27.   VkTextIOReason reason;
  28.   class VkTextIO *obj;
  29.   char *value;
  30. } VkTextIOCallback;
  31.  
  32. class VkTextIO : public VkComponent {
  33. public:
  34.  
  35.   static const char *const textCallback;
  36.  
  37.   VkTextIO(const char *name, Widget parent, const char *prompt = NULL);
  38.   ~VkTextIO();
  39.  
  40.   virtual void show();
  41.  
  42.   void clearHistory();
  43.   virtual void outputString(char *str, Boolean skipInput = True);
  44.   void outputChar(char ch, Boolean skipInput = True);
  45.   void disableRedisplay();
  46.   void enableRedisplay();
  47.  
  48.   Widget textWidget() { return text; }
  49.  
  50.   Boolean activated();
  51.   void activate();
  52.   void deactivate();
  53.  
  54.   void changePromptString (char*);
  55.  
  56.   int buffSize();
  57.  
  58.   Boolean cursorVisible();
  59.   void setCursorVisible(Boolean value);
  60.  
  61. protected:
  62.   void prepTextWidget();
  63.   void processInput(XmTextVerifyCallbackStruct *cb);
  64.   void inputChar(char ch);
  65.   void addInput(char ch);
  66.   void addInputN(char *str, int length);
  67.   void doKillLine();
  68.   void doKillWord();
  69.   void doDelete(int num, int start = -1);
  70.   void newInput();
  71.   void scrollToBottom();
  72.   void callCallback(VkTextIOReason reason, char *value);
  73.   void flushInput();
  74.   int translatePos(XmTextPosition pos);
  75.   void inputError();
  76.   void hidePrompt();
  77.   void restorePrompt();
  78.   void reallyRestorePrompt();
  79.  
  80.   virtual void doCtrlC();
  81.   virtual void doNewLine();
  82.  
  83.   static void motion_verify(Widget w, XtPointer client_data,
  84.                 XtPointer call_data);
  85.   static void modify_verify(Widget w, XtPointer client_data,
  86.                 XtPointer call_data);
  87.   static void ctrl_u(Widget w, XEvent *event, String *params,
  88.              Cardinal *num_params);
  89.   static void ctrl_c(Widget w, XEvent *event, String *params,
  90.              Cardinal *num_params);
  91.   static void ctrl_w(Widget w, XEvent *event, String *params,
  92.              Cardinal *num_params);
  93.   static Boolean prompt_stub(XtPointer clientData);
  94.  
  95.   Widget text;
  96.   char *prompt, *promptBuf, *buffer;
  97.   int bufferSize;
  98.   Boolean ignoreVerify, displayUpdated;
  99.   Pixel normalBg, readOnlyBg;
  100.   Boolean displayEnabled;
  101.   Time lastTime;
  102.   Boolean _cursorVisible;
  103.   XtWorkProcId promptID;
  104.   Boolean promptHidden;
  105. };
  106.  
  107. #endif
  108.